      SUBROUTINE WSMTSBIN  
C  
C CHANGE RECORD  
C WRITE SEDIMENT TIME-SERIES OUTPUT TO BINARY FILE.  
C AVERAGES BENTHIC FLUX RATES OVER ISMTSDT TIME STEPS (E.G., DAILY AVG).  
C  
      USE GLOBAL  
      IF(ISSDBIN .GT. 0)THEN  
        IF( MOD(ITNWQ,ISMTSDT) .EQ. 0 )THEN  
          NREC4 = NREC4+1  
          TIMTMP = TIMEBF / FLOAT(NBFCNT)  
          OPEN(UNIT=2, FILE='WQSDTS.BIN',ACCESS='DIRECT',  
     &        FORM='UNFORMATTED',STATUS='UNKNOWN', RECL=MAXRECL4)  
          READ(2, REC=1) NDUM, XDUM, XDUM,  
     &        XDT, IXDT, NPARM, NCELLS, NLAYERS  
          NDUM=NDUM  
          XDUM=XDUM  
          WRITE(2, REC=1) NREC4, TBEGAN, TIMTMP,  
     &        XDT, IXDT, NPARM, NCELLS, NLAYERS  
          WRITE(2, REC=NR6) TIMTMP  
          DO LL=2,LA  
            BFO2SUM(LL)  = BFO2SUM(LL)  / FLOAT(NBFCNT)  
            BFNH4SUM(LL) = BFNH4SUM(LL) / FLOAT(NBFCNT)  
            BFNO3SUM(LL) = BFNO3SUM(LL) / FLOAT(NBFCNT)  
            BFPO4SUM(LL) = BFPO4SUM(LL) / FLOAT(NBFCNT)  
            BFSADSUM(LL) = BFSADSUM(LL) / FLOAT(NBFCNT)  
            BFCODSUM(LL) = BFCODSUM(LL) / FLOAT(NBFCNT)  
            BFSMTSUM(LL) = BFSMTSUM(LL) / FLOAT(NBFCNT)  
            BFBSTSUM(LL) = BFBSTSUM(LL) / FLOAT(NBFCNT)  
            WRITE(2) BFO2SUM(LL), BFNH4SUM(LL), BFNO3SUM(LL),  
     &          BFPO4SUM(LL), BFSADSUM(LL), BFCODSUM(LL), BFSMTSUM(LL),  
     &          BFBSTSUM(LL)  
          ENDDO  
          INQUIRE(UNIT=2, NEXTREC=NR6)  
          CLOSE(2)  
          CALL WQZERO4  
        ENDIF  
      ENDIF  
      RETURN  
      END  

